package com.hongyang.service.impl;

import com.hongyang.entity.Midwife;
import com.hongyang.mapper.MidwifeMapper;
import com.hongyang.service.MidwifeService;
import com.hongyang.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.List;

public class MidwifeServiceImpl implements MidwifeService {
    @Override
    public Midwife selectByPrimaryKey(String id) {
        Midwife midwife=null;
        try (SqlSession session= MybatisUtil.getSqlSessionFactory().openSession()){
            MidwifeMapper mapper = session.getMapper(MidwifeMapper.class);
            midwife=mapper.selectByPrimaryKey(id);
        }
        return midwife;
    }

    @Override
    public List<Midwife> search(String hospitalId) {
        List<Midwife> list=new ArrayList<>();
        try (SqlSession session=MybatisUtil.getSqlSessionFactory().openSession()){
            MidwifeMapper mapper = session.getMapper(MidwifeMapper.class);
            list=mapper.search(hospitalId);
        }
        return list;
    }
}
